﻿/**
 * ...
 * @author wangjun
 */
class A2.utils.uPos 
{
	
	public function uPos() 
	{
		
	} 
	static public function centerMutiple(omc:MovieClip, arr:Array) {
		
		 for (var i:Number = 0; i < arr.length; i++) 
		 {
			  //arr[i].length+
		 } 
		//_root.tf.text += '\r' + mc._x
		//_root.tf.text += '\r' + mc._y
	}
	static public function center(ref_mc:MovieClip, tar_mc:MovieClip) { 
		tar_mc._x = -(tar_mc._width - ref_mc._width) * .5 + ref_mc._x;
		tar_mc._y = -(tar_mc._height - ref_mc._height) * .5 + ref_mc._y;
		//_root.tf.text += '\r' + mc._x
		//_root.tf.text += '\r' + mc._y
	}
	static public function fit(omc:MovieClip, mc:MovieClip, limit:Boolean) {
		var a:Number = omc._width;
		var b:Number = omc._height;
		var c:Number = mc._width;
		var d:Number = mc._height;
		if (a/b>c/d) {
			if (a>c && limit) {
				trace('case3');
				return 1;
			} else {
				trace('case1');
				mc._width = a;
				//mc._height =  a / (c/d) ;//错		
				//mc._height =d/(c/a) //对,等式转化
				mc._height = a*d/c;
				return a/c;
			}
		} else {
			if (b>d && limit) {
				trace('case4');
				return 1;
			} else {
				trace('case2');
				mc._height = b;
				//mc._width = d/b *a;//错		
				//mc._width = c / (d / b );//对,等式转化
				mc._width = c*b/d;
				return b/d;
			}
		}
	}
	
}